package com.eastfair.common.api;

import com.eastfair.boot.request.PageParams;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.eastfair.core.base.R;
import com.eastfair.pay.dto.PaymentDTO;
import com.eastfair.pay.dto.TransactionOrderDTO;
import com.eastfair.pay.dto.TransactionOrderPageQuery;
import com.eastfair.pay.vo.TransactionOrderVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@FeignClient(value = "mice-pay/transactionOrder")
public interface TransactionOrderFeign {

    /**
     * 保存更新交易订单
     *
     * @param transactionOrderDTO
     * @return
     */
    @PostMapping("/save")
    R<Boolean> save(@RequestBody TransactionOrderDTO transactionOrderDTO);

    /**
     * 批量新增交易订单
     *
     * @param transactionOrderList
     * @return
     */
    @PostMapping("/save/batch")
    R<Boolean> batchSave(@RequestBody List<TransactionOrderDTO> transactionOrderList);

    /**
     * 更新交易订单
     *
     * @param transactionOrderDTO
     * @return
     */
    @PostMapping("/update")
    R<Boolean> update(@RequestBody TransactionOrderDTO transactionOrderDTO);

    /**
     * 取消交易订单
     *
     * @param orderNum
     * @return
     */
    @GetMapping("/cancel")
    R<Boolean> cancel(@RequestParam("orderNum") String orderNum);


    /**
     * 分页检索 交易订单
     *
     * @param params
     * @return
     */
    @PostMapping("/queryPage")
    R<Page<TransactionOrderVO>> queryPage(@RequestBody @Validated PageParams<TransactionOrderPageQuery> params);


    /**
     * 在线支付 同步订单状态和银联交易流水号
     *
     * @param dto
     * @return
     */
    @PostMapping("/online")
    R<Boolean> onlinePayment(@RequestBody PaymentDTO dto);

    /**
     * 通过订单编号 更新订单交易状态
     *
     * @param transactionOrderDTO
     * @return
     */
    @PostMapping("/update/orderStatus")
    R updateOrderStatus(@RequestBody TransactionOrderDTO transactionOrderDTO);

    /**
     * 将没有交易流水号的订单同步荆艺
     *
     * @param orderNumList
     * @return
     */
    @PostMapping("/syncOrderToJY")
    R executeSyncOrderToJY(@RequestBody List<String> orderNumList);


}
